//  MusicPickerView.swift
//  focusOn
//
//  Created by 恒 on 2025/7/3.
//

import SwiftUI

struct MusicPickerView: View {
    @ObservedObject var viewModel: TimerViewModel

    var body: some View {
        ScrollView {
            LazyVGrid(columns: [GridItem(.adaptive(minimum: 100))], spacing: 10) {
                ForEach(viewModel.availableMusics, id: \.self) { music in
                    Button(music) {
                        viewModel.selectedMusic = music
                    }
                    .padding(12)
                    .frame(minWidth: 130, minHeight: 130)
                    .background(viewModel.selectedMusic == music ? Color.blue : Color.blue.opacity(0.1))
                    .foregroundColor(viewModel.selectedMusic == music ? Color.white : Color.black)
                    .cornerRadius(12)
                    .font(.title3)
                }
            }
            .padding()
        }
    }
}
